<?php
use App\Http\Controllers\admin\UserController;
use App\Http\Controllers\admin\IndexController;
use App\Http\Controllers\admin\RoleController;
use App\Http\Controllers\admin\NodeController;
use App\Http\Controllers\admin\ArticleController;
use App\Http\Controllers\admin\FangAttrController;
use App\Http\Controllers\admin\FangOwnerController;
use App\Http\Controllers\admin\FangController;
use App\Http\Controllers\admin\CityController;
use App\Http\Controllers\admin\NoticeController;
use App\Http\Controllers\admin\ApiUserController;

Route::group([],function (){

//    Route::get('email',function (){
//        \Mail::raw('cyf的测试邮箱发送',function (\Illuminate\Mail\Message $message){
//            $message->to('18569820614@139.com');
//            $message->subject('测试');
//        });
//    });
    //登录页
    Route::get('login',[UserController::class,'index'])->name('login');
    //执行登录
    Route::post('login',[UserController::class,'login'])->name('admin.login');
    //无权限页面
    Route::get('error',[IndexController::class,'error'])->name('admin.error');
    //登出
    Route::get('loginout',[UserController::class,'loginOut'])->name('admin.loginout');
});


Route::group(['middleware'=>'admin','as'=>'admin.'],function (){

    //后台首页
        Route::get('index',[IndexController::class,'index'])->name('index');
    //我的桌面
    Route::get('welcome',[IndexController::class,'welcome'])->name('welcome');


    //用户首页
    Route::get('user/list',[UserController::class,'userList'])->name('user.list');
    //删除用户
    Route::delete('user/del',[UserController::class,'userDel'])->name('user.del');
    //恢复删除用户
    Route::delete('user/restory',[UserController::class,'userrestory'])->name('user.restory');
    //添加用户页
    Route::get('user/add',[UserController::class,'user'])->name('user.add');
    //执行用户添加
    Route::post('user/add',[UserController::class,'userAdd'])->name('user.add');


    //用户分配角色
    Route::match(['get','post'],'user/role/{user}',[UserController::class,'role'])->name('user.role');
    //角色路由
    Route::resource('role',RoleController::class);

    //角色权限设置
    Route::match(['get','post'],'role/node/{role}',[RoleController::class,'node'])->name('role.node');
    //节点路由
    Route::resource('node',NodeController::class);

    //文章封面异步上传到本地
    Route::post('article/localfile',[ArticleController::class,'localFile'])->name('article.local_file');
    //导出文章excle表
    Route::get('article/export', [ArticleController::class,'export'])->name('article.export');
    //文章管理
    Route::resource('article',ArticleController::class);

    //上传图片到云端
    Route::post('ossfile',[FangAttrController::class,'ossfile'])->name('fangattr.ossfile');
    //房源属性管理
    Route::resource('fangattr',FangAttrController::class);


    //多图上传到本地
    Route::post('fangowner/localfile',[FangOwnerController::class,'localfile'])->name('fangowner.localfile');
    //多图上传到云端
    Route::post('fangowner/ossfile',[FangOwnerController::class,'ossfile'])->name('fangowner.osslfile');
    //删除本地图片
    Route::delete('fangowner/delpic',[FangOwnerController::class,'delpic'])->name('fangowner.delpic');
    //删除云端图片
    Route::delete('fangowner/delfile',[FangOwnerController::class,'delOssfile'])->name('fangowner.delosslfile');
    //房东管理
    Route::resource('fangowner',FangOwnerController::class);



    //多图上传到本地
    Route::post('fang/localfile',[FangController::class,'localfile'])->name('fang.localfile');
    //删除本地图片
    Route::delete('fang/delpic',[FangController::class,'delpic'])->name('fang.delpic');
    //创建生成es
    Route::get('fang/es/init',[FangController::class,'esinit'])->name('fang.esinit');
    //点改房源状态
    Route::put('fang/change',[FangController::class,'statusChange'])->name('fang.change');
    //房源信息
    Route::resource('fang',FangController::class);
    //三级联动
    Route::get('city',[CityController::class,'getcity'])->name('city');


    //改变预约状态
    Route::put('notice/change',[NoticeController::class,'statusChange'])->name('notice.status');
    //预约信息
    Route::resource('notice',NoticeController::class);


    Route::resource('apiuser',ApiUserController::class);
});

